function [ vBase, nLDof, xLDof, sfun ] = sf_hex_Q3( i_eval, n_sdim, n_vert, i_dof, xi, aInvJac, vBase )
%SF_HEX_Q3 Tricubic conforming shape function for hexahedrons (Q3).
%
%   [ VBASE, NLDOF, XLDOF, SFUN ] = SF_HEX_Q3( I_EVAL, N_SDIM, N_VERT, I_DOF, XI, AINVJAC, VBASE )
%   Evaluates conforming tricubic Q3 shape functions on hexahedrons with values defined
%   in the nodes, edges, faces, and cell center. XI is [-1..1]^3 reference coordinates.
%
%       Input       Value/[Size]           Description
%       -----------------------------------------------------------------------------------
%       i_eval      scalar:  1             Evaluate function values
%                           >1             Evaluate values of derivatives
%       n_sdim      scalar:  3             Number of space dimensions
%       n_vert      scalar:  8             Number of vertices per cell
%       i_dof       scalar: 1-n_ldof       Local basis function to evaluate
%       xi          [n_sdim]               Local coordinates of evaluation point
%       aInvJac     [n,n_sdim*n_sdim]      Inverse of transformation Jacobian
%       vBase       [n]                    Preallocated output vector
%                                                                                         .
%       Output      Value/[Size]           Description
%       -----------------------------------------------------------------------------------
%       vBase       [n]                    Evaluated function values
%       nLDof       [4]                    Number of local degrees of freedom on
%                                          vertices, edges, faces, and cell interiors
%       xLDof       [n_sdim,n_ldof]        Local coordinates of local dofs
%       sfun        string                 Function name of called shape function
%
%   See also SFLAG3, SF_HEX_Q1

% Copyright 2013-2019 Precise Simulation, Ltd.


nLDof = [8 24 24 8];
xLDof = [ -1  1  1 -1 -1  1  1 -1  -1/3 1   1/3 -1   -1    1    1   -1  -1/3 1   1/3 -1    1/3 1   -1/3 -1   -1   1   1  -1   1/3 1  -1/3 -1   -1/3 -1/3  1    1/3 -1   -1/3  1/3  1/3  1   -1/3 -1    1/3  1/3  1/3 1   -1/3 -1   1/3 -1/3 -1/3  1   1/3 -1  -1/3   -1/3  1/3  1/3 -1/3 -1/3  1/3  1/3 -1/3 ;
          -1 -1  1  1 -1 -1  1  1  -1  -1/3 1    1/3 -1   -1    1    1  -1  -1/3 1    1/3 -1   1/3  1   -1/3 -1  -1   1   1  -1   1/3 1   -1/3 -1/3 -1   -1/3  1    1/3 -1/3 -1/3 -1    1/3  1   -1/3 -1/3  1/3 -1   1/3  1   -1/3 1/3  1/3 -1   -1/3 1    1/3 1/3   -1/3 -1/3  1/3  1/3 -1/3 -1/3  1/3  1/3 ;
          -1 -1 -1 -1  1  1  1  1  -1  -1  -1   -1   -1/3 -1/3 -1/3 -1/3 1   1   1    1   -1  -1   -1   -1    1/3 1/3 1/3 1/3 1   1   1    1   -1   -1/3 -1/3 -1/3 -1/3  1   -1   -1/3 -1/3 -1/3 -1/3  1   -1    1/3 1/3  1/3  1/3 1   -1    1/3  1/3 1/3  1/3 1     -1/3 -1/3 -1/3 -1/3  1/3  1/3  1/3  1/3 ];
sfun  = 'sf_hex_Q3';


switch i_eval

  case 1

    switch i_dof
      case 1
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 2
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 3
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 4
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 5
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 6
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 7
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(2) + 1)*(xi(3) + 1)/4096;
      case 8
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) + 1)/4096;
      case 9
        vBase = (3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 10
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 11
        vBase = (3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 12
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 13
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 14
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 15
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) + 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 16
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 17
        vBase = -(3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 18
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 19
        vBase = -(3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) + 1)/4096;
      case 20
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 21
        vBase = -(3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 22
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 23
        vBase = -(3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 24
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 25
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 26
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 27
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) + 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 28
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 29
        vBase = (3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 30
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 31
        vBase = (3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) + 1)/4096;
      case 32
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 33
        vBase = -(3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 34
        vBase = -(3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 35
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 36
        vBase = -(3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 37
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 38
        vBase = (3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 39
        vBase = (3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 40
        vBase = (3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 41
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 42
        vBase = (3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 43
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 44
        vBase = -(3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 45
        vBase = -(3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 46
        vBase = -(3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 47
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 48
        vBase = -(3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 49
        vBase = (3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 50
        vBase = (3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 51
        vBase = (3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 52
        vBase = (3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 53
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) + 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 54
        vBase = (3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) + 1)*(xi(3) - 1)/4096;
      case 55
        vBase = -(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 56
        vBase = -(3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) + 1)/4096;
      case 57
        vBase = (3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 58
        vBase = -(3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 59
        vBase = (3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 60
        vBase = -(3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) - 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 61
        vBase = -(3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 62
        vBase = (3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) - 1)*(9*xi(2) + 9)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 63
        vBase = -(3*xi(1) + 1)*(9*xi(1) + 9)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
      case 64
        vBase = (3*xi(1) - 1)*(9*xi(1) + 9)*(3*xi(2) + 1)*(9*xi(2) + 9)*(3*xi(3) + 1)*(9*xi(3) + 9)*(xi(1) - 1)*(xi(2) - 1)*(xi(3) - 1)/4096;
    end

  case {2,3,4}

    switch i_dof
      case 1
        dNdxi1 = ((3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) - 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = ((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) - 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = ((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 2
        dNdxi1 = ((3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) - 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = -((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) - 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = -((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 3
        dNdxi1 = -((3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) - 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = -((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) - 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = ((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 4
        dNdxi1 = -((3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) - 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = ((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) - 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = -((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 5
        dNdxi1 = -((3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = -((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = ((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 6
        dNdxi1 = -((3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = ((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = -((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 7
        dNdxi1 = ((3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = ((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = ((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 8
        dNdxi1 = ((3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = -((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = -((3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 9
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) - 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 10
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) - 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 11
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) - 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = (9*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = -(9*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 12
        dNdxi1 = (9*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) - 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 13
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 14
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 15
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 16
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 17
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 18
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 19
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = -(9*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = -(9*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 20
        dNdxi1 = -(9*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 21
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) - 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = (9*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = (9*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 22
        dNdxi1 = (9*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) - 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 23
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) - 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 24
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) - 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 25
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 26
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 27
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 28
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 29
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = -(9*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = (9*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 30
        dNdxi1 = -(9*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 31
        dNdxi1 = -(9*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = (9*(3*xi(1) - 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 32
        dNdxi1 = (9*(3*xi(2) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = (9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = -(9*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 33
        dNdxi1 = (81*(3*xi(2) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = (81*(3*xi(1) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = (81*(3*xi(1) - 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 34
        dNdxi1 = (81*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = (81*(3*xi(1) - 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = (81*(3*xi(1) - 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 35
        dNdxi1 = (81*(3*xi(2) - 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = -(81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = -(81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 36
        dNdxi1 = -(81*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = -(81*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = (81*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 37
        dNdxi1 = -(81*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = (81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = -(81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 38
        dNdxi1 = -(81*(3*xi(2) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = -(81*(3*xi(1) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = (81*(3*xi(1) - 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 39
        dNdxi1 = (81*(3*xi(2) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = -(81*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = -(81*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 40
        dNdxi1 = (81*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = -(81*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = -(81*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 41
        dNdxi1 = -(81*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = -(81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = (81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 42
        dNdxi1 = -(81*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = (81*(3*xi(1) - 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = -(81*(3*xi(1) - 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 43
        dNdxi1 = (81*(3*xi(2) - 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = (81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = (81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 44
        dNdxi1 = -(81*(3*xi(2) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = (81*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = -(81*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 45
        dNdxi1 = -(81*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = -(81*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = (81*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 46
        dNdxi1 = -(81*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = (81*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = -(81*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 47
        dNdxi1 = (81*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = (81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = (81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 48
        dNdxi1 = (81*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = -(81*(3*xi(1) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = -(81*(3*xi(1) - 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 49
        dNdxi1 = -(81*(3*xi(2) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = -(81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = (81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 50
        dNdxi1 = (81*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = (81*(3*xi(1) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = (81*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 51
        dNdxi1 = -(81*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = (81*(3*xi(1) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = -(81*(3*xi(1) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 27*xi(3)^2 + 18*xi(3) + 1))/4096;
      case 52
        dNdxi1 = -(81*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = -(81*(3*xi(1) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(2)^2 + 18*xi(2) + 1))/4096;
        dNdxi3 = (81*(3*xi(1) - 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 53
        dNdxi1 = -(81*(3*xi(2) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(1)^2 + 18*xi(1) - 1))/4096;
        dNdxi2 = (81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = -(81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 54
        dNdxi1 = (81*(3*xi(2) - 1)*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = (81*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(27*xi(2)^2 + 18*xi(2) - 1))/4096;
        dNdxi3 = (81*(3*xi(1) + 1)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 55
        dNdxi1 = (81*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 27*xi(1)^2 + 18*xi(1) + 1))/4096;
        dNdxi2 = -(81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = -(81*(3*xi(1) - 1)*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 56
        dNdxi1 = (81*(3*xi(2) + 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = -(81*(3*xi(1) - 1)*(3*xi(3) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = -(81*(3*xi(1) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(27*xi(3)^2 + 18*xi(3) - 1))/4096;
      case 57
        dNdxi1 = -(729*(3*xi(2) - 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = -(729*(3*xi(1) - 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = -(729*(3*xi(1) - 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 58
        dNdxi1 = -(729*(3*xi(2) - 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = (729*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = (729*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 59
        dNdxi1 = (729*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = (729*(3*xi(1) + 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = -(729*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 60
        dNdxi1 = (729*(3*xi(2) + 1)*(3*xi(3) - 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = -(729*(3*xi(1) - 1)*(3*xi(3) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = (729*(3*xi(1) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(3)^2 + 2*xi(3) + 3))/4096;
      case 61
        dNdxi1 = (729*(3*xi(2) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = (729*(3*xi(1) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = -(729*(3*xi(1) - 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 62
        dNdxi1 = (729*(3*xi(2) - 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = -(729*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/4096;
        dNdxi3 = (729*(3*xi(1) + 1)*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 63
        dNdxi1 = -(729*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/4096;
        dNdxi2 = -(729*(3*xi(1) + 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = -(729*(3*xi(1) + 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
      case 64
        dNdxi1 = -(729*(3*xi(2) + 1)*(3*xi(3) + 1)*(xi(2) - 1)*(xi(2) + 1)*(xi(3) - 1)*(xi(3) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/4096;
        dNdxi2 = (729*(3*xi(1) - 1)*(3*xi(3) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(3) - 1)*(xi(3) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/4096;
        dNdxi3 = (729*(3*xi(1) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(3)^2 + 2*xi(3) - 3))/4096;
    end

    if     ( i_eval==2 )   % x-derivative.

      vBase = aInvJac(:,1)*dNdxi1 + aInvJac(:,2)*dNdxi2 + aInvJac(:,3)*dNdxi3;

    elseif ( i_eval==3 )   % y-derivative.

      vBase = aInvJac(:,4)*dNdxi1 + aInvJac(:,5)*dNdxi2 + aInvJac(:,6)*dNdxi3;

    elseif ( i_eval==4 )   % z-derivative.

      vBase = aInvJac(:,7)*dNdxi1 + aInvJac(:,8)*dNdxi2 + aInvJac(:,9)*dNdxi3;
    end

  case {22,23,24,32,33,34,42,43,44}   % Evaluation of second order derivatives.
    error('sf_hex_Q3: second order derivative evaluation not supported.')

  otherwise
    vBase = 0;

end
